package com.itheima.mapper;

import com.itheima.domain.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    // 查询所有
    @Select("select * from user")
    public List<User> findAll();

    // 根据id查询
    @Select("select * from user where id = #{id}")
    public User findById(int i);

    // 查询记录数
    @Select("select count(*) from user ")
    public int findCount();

    // 模糊查询
    @Select("select * from user where name like concat('%',#{name},'%')")
    public List<User> findByName(String s);

    // 添加用户
    @Insert("insert into user values (null,#{name},#{age})")
    public void addUser(User user);

    // 修改用户
    @Update("update user set name = #{name},age = #{age} where id = #{id}")
    public void updateUser(User user);

    // 删除用户
    @Delete("delete from user where id = #{id}")
    public void deleteUser(int i);
}
